#!/bin/bash -e

function info() {
    echo Usage: `basename $0` '[-nrb] r1 r2 interval'
    exit 1
}

while getopts ":p:f:n:r:b:" opt; do
    case  $opt  in
        p) out_prefix=$OPTARG;;
        f) suffix=$OPTARG;;
        n) name=$OPTARG;;
        r) read_th=$OPTARG;;
        b) bed=$OPTARG;;
        *) info;;
    esac
done
shift $(($OPTIND - 1))

if [ $# -lt 1 ]; then info; fi

export var=/mnt/ilustre/app/medical/tools/script/var
. $var


if test -z "$name"; then
name=test
fi
interval=$3
bed=$3


fp.sh -p$out_prefix $1 $2

aln0818.sh -s$name -p$out_prefix -b$bed $out_prefix.r1.fq $out_prefix.r2.fq

realign_bt.sh -p$out_prefix -i$interval $out_prefix.sort.bam

umi.sh -p$out_prefix $out_prefix.realn.bam

# recal0630.sh -l $bed -p$out_prefix $out_prefix.markdup.bam

hap0702.sh -p$out_prefix $out_prefix.umi.bam $bed

# find . -name '*.g.vcf' > $out_prefix.gvcf.list
# gvcf_combine.sh -p$out_prefix $out_prefix.gvcf.list
gvcf_gt0702.sh -p$out_prefix $out_prefix.g.vcf

. $cmd_done